package com.qh.resourcehub.usersphere.controller;

import com.qh.resourcehub.usersphere.entity.SyncUnifiedUserRequest;
import com.qh.resourcehub.usersphere.service.SyncUnifiedUserService;
import com.qh.resourcehub.utils.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/*
    接收用户、部门、用户-一人多岗信息
 * @Description:
 * @param null
 * @return
 * @Author: Y6
 * @Date: 2024/6/18 15:38
 */
@RestController
public class SyncUnifiedUserController {

    @Autowired
    SyncUnifiedUserService departmentService;


    @PostMapping(value = "/syncUnifiedUser")
    public ApiResponse syncUnifiedUser(@RequestBody SyncUnifiedUserRequest syncUnifiedUserRequest) {
        try {
            int result = departmentService.SyncUnifiedUser(syncUnifiedUserRequest);
            if (result == 1) {
                return ApiResponse.succeed(syncUnifiedUserRequest.getSyncRecordId());
            } else if (result == 2){
                return ApiResponse.succee(syncUnifiedUserRequest.getSyncRecordId());
            }else {
                return ApiResponse.error(syncUnifiedUserRequest.getSyncRecordId());
            }
        } catch (Exception e) {
            return ApiResponse.error( syncUnifiedUserRequest.getSyncRecordId());
        }
    }

}
